﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dynamicOrderItemAdd.aspx.cs" Inherits="PeisongWeb.admin.dynamicOrderItemAdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagName="top" Src="controls/top.ascx" TagPrefix="uc1" %>
<%@ Register TagName="menu" Src="controls/menu.ascx" TagPrefix="uc2" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>提前订单添加商品</title>
    <style type="text/css">
    .header-row{}
    </style>
    <!--#include file="style.inc"-->
    <script src="/app_common/scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            $('#chkSelectedAll').click(function() {
                if ($(this).attr('checked')) {
                    $(':checkbox', $('#admin_list_content')).attr('checked', true);
                } else {
                    $(':checkbox', $('#admin_list_content')).attr('checked', null);
                }
            });
        });

        function checktxtlength(obj) {
            if (obj.value.length > 50) {
                obj.select();
                alert("输入长度请不要超过50个字符（一个汉字占两个字符）！");
            }
        }

        function checktxttype(obj) {
            var test = /^\d+(\.\d{1,2})?$/;
            if (test.test(obj.value)) {
                if (obj.value == "0") {
                    obj.value = "1"
                    return true;
                }
                else
                    return true;
            }
            else {
                obj.value = "1"
                return true;
            }
        }

        function delSelectedConfirm(obj) {
            var k = [];
            $('#tablerange').find("tr").siblings().css('color', 'black').each(function() {
                if ($(this).find('td').eq(5).find('input').attr('checked')) {
                    var productid = $(this).find('td').eq(0).find('input').eq(0).val();
                    var businessnature = $(this).find('td').eq(0).find('input').eq(1).val();
                    var amount = $(this).find('td').eq(3).find('input').eq(0).val();
                    var remark = $(this).find('td').eq(4).find('input').eq(0).val();
                    k.push(productid + '|' + businessnature + '!' + amount + '*' + remark);
                }
            });

           
            if (k != 0) {
                $('#hdSelectedProductIds').val(k.join(','));
                return confirm('你确定要添加这' + k.length  + '项吗?');
            } else {
                alert('无任何可以添加的项.');
                return false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="sm1" runat="server">
    </asp:ScriptManager>
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <uc1:top ID="Top1" runat="server" />
    <uc2:menu ID="Menu1" runat="server" />
    <div id="admin-body">
        <h2 class="section-cms">提前订单添加商品</h2>
        <span>
            <ext:Button runat="server" ID="btnReturn" Text="返回" AutoPostBack="true" 
            Icon="ArrowSwitch" onclick="btnReturn_Click"></ext:Button>
        </span>
        <p>
            &nbsp;</p>
        <ext:Panel ID="Panel1" runat="server" Title="企业日常采购初始化" BodyStyle="padding:5px 5px 0"
            Width="960" Frame="true" ButtonAlign="Center">
            <Body>
                <div id="admin_edit_content_search">
                    <asp:UpdatePanel runat="server" ID="UP1">
                        <Triggers>
                            <asp:PostBackTrigger ControlID="lbn_search" />
                        </Triggers>
                        <ContentTemplate>
                            <ul>
                                <li style="width: 175px;">
                                    <label>
                                        大 类：</label>
                                    <asp:DropDownList runat="server" ID="ddl_CategoryRoot" DataTextField="parentname" DataValueField="parentId"
                                        AutoPostBack="True" OnSelectedIndexChanged="ddl_CategoryRoot_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </li>
                                <li style="width: 175px;">
                                    <label>
                                        小 类：</label>
                                    <asp:DropDownList runat="server" ID="ddl_CategorySub" DataTextField="childname" DataValueField="categoryId">
                                    </asp:DropDownList>
                                </li>
                                <li style="width: 220px;">
                                    <label style="width: 75px;">
                                        商品编号:</label>
                                    <asp:TextBox ID="txt_ProductNo" runat="server" Width="120px"></asp:TextBox>
                                </li>
                                <li style="width: 220px;">
                                    <label style="width: 75px;">
                                        商品名称:</label>
                                    <asp:TextBox ID="txt_ProductName" runat="server" Width="120px"></asp:TextBox>
                                </li>
                                <li style="width: auto;">
                                    <asp:LinkButton ID="lbn_search" runat="server" Text="［搜索］" CausesValidation="false"
                                        OnClick="lbn_search_Click"></asp:LinkButton>
                                    <asp:LinkButton ID="lbn_reset" runat="server" Text="[重置]" CausesValidation="false"
                                        OnClick="lbn_reset_Click"></asp:LinkButton>
                                </li>
                            </ul>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
            </Body>
        </ext:Panel>
        <p>
            &nbsp;</p>
        <div id="admin_list_content" style="width: 960px;">
            <table id="tablerange" cellpadding="0" cellspacing="0">
                <tr class="header-row">
                    <th width="8%" bgcolor="#C0D5F0">
                        商品编号
                    </th>
                    <th width="25%" bgcolor="#C0D5F0">
                        商品名称
                    </th>
                    <th width="15%" bgcolor="#C0D5F0">
                        商品价格
                    </th>
                    <th width="10%" bgcolor="#C0D5F0">
                        数量
                    </th>
                    <th width="32%" bgcolor="#C0D5F0">
                        添加备注
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                <asp:Repeater ID="rpt_list" runat="server">
                    <ItemTemplate>
                        <tr class='<%# Container.ItemIndex%2==0? "row-alt":"alt"  %>' style="color:Black">
                            
                            <td >
                                <%# Eval("productNo")%>
                                <asp:HiddenField ID="hid_productId" runat="server" Value='<%#Eval("productId") %>' />
                                <asp:HiddenField ID="hidNature" runat="server" Value='<%#Eval("businessnature") %>' />
                            </td>
                            <td >
                                <a target="_blank" href="../user_productDetail_<%#Eval("productId")%>.html">
                                    <asp:Label runat="server" ID="lbl_proName" Text='<%# Eval("Name")%>'></asp:Label>
                                </a>
                            </td>
                            <td >
                                ￥<asp:Label runat="server" ID="lbl_price" Text='<%#string.Format("{0:F2}", Eval("newprice"))%>'></asp:Label>
                                /<asp:Label runat="server" ID="lbl_unit" Text='<%#Eval("unit")%>'></asp:Label>
                            </td>
                            <td  align="center">
                                <asp:TextBox ID="txtQuantity" onblur='checktxttype(this);' onafterpaste='checkCountNum(this);'
                                    runat="server" Text="1" MaxLength="8" Width="60px"></asp:TextBox>
                            </td>
                            <td >
                                <asp:TextBox ID="txtNote" runat="server" Width="150px" MaxLength="200"></asp:TextBox>
                            </td>
                            <td>
                                <asp:CheckBox runat="server" ID="chkSelected" productId='<%# DataBinder.Eval(Container.DataItem,"productId") %>' />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                <tr>
                    <td colspan="7">
                        <asp:Button runat="server" ID="btnDelSelected" Text="添加选择项" OnClientClick="return delSelectedConfirm(this);"
                            OnClick="btnDelSelected_Click" />
                        <%--<asp:Button ID="btnSecondLevel" runat="server" Text="按大类二级选用" 
                            OnClientClick='return confirm("你确定要添加该大类下所有二级商品吗?");' CommandName="0"
                            OnCommand="btnSecondLevel_Command" />
                        <asp:Button ID="btnSecondLevel0" runat="server" Text="按小类二级选用" 
                            OnClientClick='return confirm("你确定要添加该小类下所有二级商品吗?");' CommandName="1" 
                            OnCommand="btnSecondLevel_Command" />--%>
                    </td>
                </tr>
            </table>
            <div id="page">
                <webdiyer:AspNetPager ID="AspNetPager1" NumericButtonType="Text" MoreButtonType="Text"
                    OnPageChanged="AspNetPager1_PageChanged" runat="server" AlwaysShow="True" PageSize="20"
                    InvalidPageIndexErrorMessage="无效页码" PageIndexOutOfRangeErrorMessage="页码超出范围"
                    ShowCustomInfoSection="Left" CustomInfoHTML=" 每页%PageSize%条记录 | 总共%RecordCount%条记录 "
                    CustomInfoTextAlign="Left" HorizontalAlign="Right" NextPageText="下一页" FirstPageText="首页"
                    LastPageText="末页" PrevPageText="上一页">
                </webdiyer:AspNetPager>
            </div>
        </div>
    </div>
    <asp:HiddenField runat="server" ID="hdSelectedProductIds" />
    </form>
</body>
</html>
